Skip to content

fix(storage): prevent indefinite hang when calling Close() on async appendable uploads#16255

Open
kalragauri wants to merge 1 commit into
googleapis:mainfrom
kalragauri:feat/appendable-close
Open

fix(storage): prevent indefinite hang when calling Close() on async appendable uploads#16255
kalragauri wants to merge 1 commit into
googleapis:mainfrom
kalragauri:feat/appendable-close

Conversation

@kalragauri

Copy link
Copy Markdown
Contributor

Currently, when closing an appendable upload, the SDK delegates a kFlushAndClose signal to the underlying gRPC stream. However, in writer_connection_impl.cc, the caller was invoking Finish() immediately after flushing the write, failing to consume the server's final BidiWriteObjectResponse which effectively hangs the stream on the completion queue. This PR fixes the behavior to properly abide by the gRPC stream contract.

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Jul 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates AsyncWriterConnectionImpl::OnClose to perform an asynchronous Read and OnQuery check before finishing the connection, and updates the corresponding unit and integration tests. A critical lifetime issue was identified in the new asynchronous chain, where capturing this by raw pointer in the .then() continuations could lead to a use-after-free if the connection object is destroyed before the chain completes. It is recommended to capture a shared pointer via shared_from_this() to extend the lifetime of the connection object.

Comment thread google/cloud/storage/internal/async/writer_connection_impl.cc
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.26%. Comparing base (ce70c7d) to head (4dd66b9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16255      +/-   ##
==========================================
- Coverage   92.26%   92.26%   -0.01%     
==========================================
  Files        2214     2214              
  Lines      206307   206326      +19     
==========================================
+ Hits       190355   190371      +16     
- Misses      15952    15955       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalragauri kalragauri marked this pull request as ready for review July 14, 2026 07:10
@kalragauri kalragauri requested review from a team as code owners July 14, 2026 07:10
@kalragauri kalragauri requested a review from v-pratap July 14, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant